l = [1, 2, 3, 4, 5, 6, 7, 8, 9]

# 循环
for i in l:
    print(i)

# 循环的时候获取下标
for index, i in enumerate(l):
    print(index, i)

# while循环

i = 0
while i <= 100:
    print(i)
    i += 1

user = {
    "001": "张三",
    "002": "李四",
    "003": "王五"
}
# 循环key，通过ley获取value
for key in user.keys():
    print(key, user[key])

# 直接循环获取kv
for k, v in user.items():
    print(k, v)

# 对集合中的元素进行处理
l = [1, 2, 3, 4, 5, 6, 7, 8, 9]
new_l = []
for i in l:
    new_l.append(i ** 2)

print(new_l)

# 列表推导式，对上面代码的简写
l2 = [i ** 2 for i in l]
print(l2)
